package com.wyc;

import java.util.Map;
import java.util.SortedMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListMap;

/**
 * @author
 */
public class MethodCostTimeCount {

    /**
     * key : 方法名
     * value : sortedMap
     *         key : 方法调用结束的时间点，毫秒数
     *         value : 方法调用的耗时
     */
    public static Map<String, SortedMap<Long, Long>> methodCount = new ConcurrentHashMap<>();

    public static void put(String method, Long time, Long cost){
        SortedMap<Long, Long> sortedMap = methodCount.get(method);
        if(sortedMap == null){
            sortedMap = new ConcurrentSkipListMap();
            methodCount.put(method, sortedMap);
        }
        sortedMap.put(time, cost);
    }

    public static Map<String, SortedMap<Long, Long>> getMethodCount() {
        return methodCount;
    }
}
